﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WpfControlDemo.ViewModels.控件.输入控件;

namespace WPFCouse
{
    /// <summary>
    /// DispatcherWindow.xaml 的交互逻辑
    /// </summary>
    public partial class DispatcherWindow : Window
    {
      
        public DispatcherWindow()
        {
            InitializeComponent();
            
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // lblInfo.Content = "欢迎来到朝夕教育！";
            //错误的，UI线程所拥有
            Thread th = new Thread(() =>
              {
                  //很耗时的操作。。。。。很长时间
                  this.Dispatcher.Invoke(() =>
                  {
                    //UI 线程
                      lblInfo.Content = "欢迎来到朝夕教育！";
                  });
                  
              });
            th.Start();
        }
    }
}
